package ljl.alg.jianzhioffer.round3.medium;

public class _56_singleNumbers {

    public int[] singleNumbers(int[] nums) {
        int x = 0;
        for (int num : nums) {
            x ^= num;
        }
        int lowB = x ^ (x - 1) & x;
        int a = 0, b = 0;
        for (int num : nums) {
            if ((num & lowB) != 0)
                a ^= num;
            else
                b ^= num;
        }
        return new int[] {a, b};
    }

}
